<template>
  <a-layout>
    <!-- 左边菜单：可收起、隐藏trigger、宽度240px、触发xl(宽>1200px)响应式布局 -->
    <a-layout-sider class="sjht-layout-sider" v-model="collapsed" collapsible :trigger="null" :width="240" breakpoint="xl">
      <span class="sjht-layout-sider-logo">智慧餐厅后台管理系统</span>
      <sjht-sider-menu class="sjht-layout-sider-menu" :collapsed="collapsed" />
    </a-layout-sider>
    <!-- 右边内容 -->
    <a-layout class="sjht-layout-body">
      <!-- 头部 -->
      <a-layout-header class="sjht-layout-header">
        <a-icon :type="collapsed ? 'menu-unfold' : 'menu-fold'" @click="() => (collapsed = !collapsed)" />
        <sjht-header-menu />
      </a-layout-header>
      <!-- 主页 -->
      <a-layout-content class="sjht-layout-content" id="maincontent">
        <router-view />
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<script>
import { Layout } from 'ant-design-vue'
import SjhtSiderMenu from './menus/SiderMenu' //左边菜单组件
import SjhtHeaderMenu from './menus/HeaderMenu'
export default {
  data() {
    return {
      collapsed: false //收起状态
    }
  },
  components: {
    [Layout.name]: Layout,
    [Layout.Sider.name]: Layout.Sider,
    [Layout.Header.name]: Layout.Header,
    [Layout.Content.name]: Layout.Content,
    [SjhtSiderMenu.name]: SjhtSiderMenu,
    [SjhtHeaderMenu.name]: SjhtHeaderMenu
  }
}
</script>

<style lang="less">
@zindex: 10;
.sjht-layout {
  &-sider {
    z-index: @zindex;
    height: 100vh;
    min-height: 100vh;
    overflow-x: hidden;
    box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
    .ant-layout-sider-children {
      display: flex;
      flex-direction: column;
      overflow-x: hidden;
    }
    &-logo {
      z-index: @zindex + 1;
      height: 64px;
      line-height: 64px;
      padding: 0 12px 0 24px;
      background: #001529;
      color: rgba(255, 255, 255, 0.85);
      font-size: 18px;
      font-weight: 600;
      overflow: hidden;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    &-menu {
      flex: 1;
      width: calc(100% + 17px) !important;
      position: relative;
      overflow-y: scroll;
      overflow-x: hidden;
    }
  }
  &-body {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    min-height: 100vh;
    height: 100vh;
    transition: all 0.2s;
  }
  &-header {
    z-index: @zindex + 1;
    padding: 0 15px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    i {
      font-size: 22px;
    }
    &:after {
      display: block;
      clear: both;
      content: '';
    }
  }
  &-content {
    flex: 1;
    position: relative;
    overflow-x: hidden;
  }
}
</style>
